package com.education.basic.service.impl;

import com.education.basic.dao.*;
import com.education.basic.entity.*;
import com.education.basic.resource.Major;
import com.education.basic.resource.Title;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;


/**
 */
@Service("systemDataCountService")
public class SystemDataCountService
{
    @Resource
    private AdministratorDao administratorDao;
    @Resource
    private DepartmentDao departmentDao;
    @Resource
    private FeeInfoDAO feeInfoDAO;
    @Resource
    private PositionDao positionDao;
    @Resource
    private PrivilegesDao privilegesDao;
    @Resource
    private PrivilegesItemDao privilegesItemDao;
    @Resource
    private ProfessionDao professionDao;
    @Resource
    private ScoreDAO scoreDAO;
    @Resource
    private StudentDao studentDao;
    @Resource
    private TeacherDao teacherDao;
    @Resource
    private TeachInfoDAO teachInfoDAO;

   @Transactional
   public Map<String,Long> count()
   {
       Map<String,Long> count = new HashMap<String, Long>();
       Map<String,Object> params = new HashMap<String,Object>();
       count.put("管理员",administratorDao.count(params, Administrator.class));
       count.put("院系",departmentDao.count(params, Department.class));
       count.put("学费",feeInfoDAO.count(params, FeeInfo.class));
       count.put("职称", (long)Title.values().length);
       count.put("权限",privilegesDao.count(params,Privileges.class));
       count.put("权限明细",privilegesItemDao.count(params,PrivilegesItem.class));
       count.put("专业", (long)(Major.values().length));
       count.put("成绩",scoreDAO.count(params, Score.class));
       count.put("学生",studentDao.count(params, Student.class));
       count.put("教师",teacherDao.count(params, Teacher.class));
       count.put("任课",teachInfoDAO.count(params, TeachInfo.class));
       return count;
   }

    @Transactional
    public Map<String,Long> countAdmin()
    {
        Map<String,Long> count = new HashMap<String, Long>();
        Map<String,Object> params = new HashMap<String,Object>();
        params.put("level",1);
        Map<String,Object> params2 = new HashMap<String,Object>();
        params2.put("level",2);
        Map<String,Object> params3 = new HashMap<String,Object>();
        params3.put("level",3);
        Map<String,Object> params4 = new HashMap<String,Object>();
        params4.put("level",4);
        count.put("超级管理员",administratorDao.count(params, Administrator.class));
        count.put("院系管理员",departmentDao.count(params2, Administrator.class));
        count.put("任课管理员",feeInfoDAO.count(params3, Administrator.class));
        count.put("临时管理员",feeInfoDAO.count(params4, Administrator.class));
        return count;
    }



    public DepartmentDao getDepartmentDao() {
        return departmentDao;
    }

    public void setDepartmentDao(DepartmentDao departmentDao) {
        this.departmentDao = departmentDao;
    }

    public FeeInfoDAO getFeeInfoDAO() {
        return feeInfoDAO;
    }

    public void setFeeInfoDAO(FeeInfoDAO feeInfoDAO) {
        this.feeInfoDAO = feeInfoDAO;
    }

    public AdministratorDao getAdministratorDao() {
        return administratorDao;
    }

    public void setAdministratorDao(AdministratorDao administratorDao) {
        this.administratorDao = administratorDao;
    }

    public PositionDao getPositionDao() {
        return positionDao;
    }

    public void setPositionDao(PositionDao positionDao) {
        this.positionDao = positionDao;
    }

    public PrivilegesDao getPrivilegesDao() {
        return privilegesDao;
    }

    public void setPrivilegesDao(PrivilegesDao privilegesDao) {
        this.privilegesDao = privilegesDao;
    }

    public PrivilegesItemDao getPrivilegesItemDao() {
        return privilegesItemDao;
    }

    public void setPrivilegesItemDao(PrivilegesItemDao privilegesItemDao) {
        this.privilegesItemDao = privilegesItemDao;
    }

    public ProfessionDao getProfessionDao() {
        return professionDao;
    }

    public void setProfessionDao(ProfessionDao professionDao) {
        this.professionDao = professionDao;
    }

    public ScoreDAO getScoreDAO() {
        return scoreDAO;
    }

    public void setScoreDAO(ScoreDAO scoreDAO) {
        this.scoreDAO = scoreDAO;
    }

    public StudentDao getStudentDao() {
        return studentDao;
    }

    public void setStudentDao(StudentDao studentDao) {
        this.studentDao = studentDao;
    }

    public TeacherDao getTeacherDao() {
        return teacherDao;
    }

    public void setTeacherDao(TeacherDao teacherDao) {
        this.teacherDao = teacherDao;
    }

    public TeachInfoDAO getTeachInfoDAO() {
        return teachInfoDAO;
    }

    public void setTeachInfoDAO(TeachInfoDAO teachInfoDAO) {
        this.teachInfoDAO = teachInfoDAO;
    }
}
